package com.example.backend;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class UserService {

    @Autowired
    @Qualifier("messageJdbcTemplate")
    private JdbcTemplate jdbcTemplate;

    public boolean isUserExists(String username) {
        String query = "SELECT COUNT(*) FROM user WHERE username = ?";
        int count = jdbcTemplate.queryForObject(query, new Object[]{username}, Integer.class);
        return count > 0;
    }
}
